﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Microsoft.Kinect;

namespace KinectStudio.ModuliFile
{
    /// <summary>
    /// Interaction logic for ElencaDispositivi.xaml
    /// </summary>
    public partial class ElencaDispositivi : Window
    {
        
        public ElencaDispositivi()
        {
            InitializeComponent();
        }

        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem menuCliccato = (MenuItem)e.OriginalSource;
            switch (menuCliccato.Header.ToString())
            {
                case "Esci":
                    this.Close();
                    break;
            }
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ui_DataGridSensori.ItemsSource = ricavaListaSensoriCollegati();
        }

        private List<Sensore> ricavaListaSensoriCollegati()
        {
            int contatore = 0;
            List<Sensore> listaSensori = new List<Sensore>(); 
            foreach (KinectSensor kinectRilevato in KinectSensor.KinectSensors)
            {
                if (kinectRilevato.Status == KinectStatus.Connected)
                {
                    listaSensori.Add(new Sensore() { numero = contatore, istanza = kinectRilevato.DeviceConnectionId });
                    contatore++;
                }
            }            
            return listaSensori;
        }
    }
}
